package com.dailyblue.java.project.oa.commons.bean;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

@Data
public class EmpDetails implements UserDetails {

    private Emp emp;
    private List<GrantedAuthority> authorities;

    public EmpDetails(Emp emp, List<GrantedAuthority> authorities) {
        this.emp = emp;
        this.authorities = authorities;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return emp.getEpass();
    }

    @Override
    public String getUsername() {
        return emp.getEcode();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
